//
//  ShowVideoViewController.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 2017/9/19.
//  Copyright © 2017年 com.xtion.crm. All rights reserved.
//

#import "ShowVideoViewController.h"
#import "KZVideoPlayer.h"

NSString *const ShowVideoViewControllerVideoAbsolutePathParamKey = @"ShowVideoViewControllerVideoAbsolutePathParamKey";

@interface ShowVideoViewController ()
{
    NSString *_videoAbsolutePath;
    UIView *showView;
}
@end

@implementation ShowVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBackNavigateItemTitle:@"视频播放"]; 
    self.view.backgroundColor = [UIColor blackColor];
    
    _videoAbsolutePath = self.param[ShowVideoViewControllerVideoAbsolutePathParamKey];
    
    CGSize videoViewSize = [KZVideoConfig videoViewDefaultSize];
    showView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, videoViewSize.width, videoViewSize.height)];
    showView.centerY = self.view.centerY;
    
    [self.view addSubview:showView];
    
    [self showVideo];
}

- (void)showVideo{

    for (UIView *subview in showView.subviews) {
        [subview removeFromSuperview];
    }
    
    NSURL *videoUrl = [NSURL fileURLWithPath:_videoAbsolutePath];
    KZVideoPlayer *player = [[KZVideoPlayer alloc] initWithFrame:showView.bounds videoUrl:videoUrl];
    [showView addSubview:player];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
